<html>
<head><meta charset="utf-8"><title>rerun-if-changed on directory · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html">rerun-if-changed on directory</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221745787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221745787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221745787">(Jan 06 2021 at 08:59)</a>:</h4>
<p>Hi,</p>
<p>Slightly odd question - does rerun-if-changed=PATH work if PATH is a directory?  I want to embed some data into my program and I'd like my build script to compute the set of embeds needed and write out an appropriate .rs file to OUT_DIR to be included.</p>
<p>If it's not likely to be reliable I'll use an index file of some kind, but if rerun-if-changed on a directory ought to work nicely then I'd prefer to use that.</p>
<p>Thanks,</p>
<p>Daniel.</p>



<a name="221753659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221753659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221753659">(Jan 06 2021 at 10:45)</a>:</h4>
<p>IIRC no it does not.</p>



<a name="221755195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221755195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221755195">(Jan 06 2021 at 11:05)</a>:</h4>
<p>It does “work” on a directory, but it only checks the mtime, it doesn’t traverse the directory. <a href="https://github.com/rust-lang/cargo/issues/2599">https://github.com/rust-lang/cargo/issues/2599</a></p>
<p>FWIW this is also a feature I wish cargo had, as <code>fluent-templates</code> basically embeds a directory of localisation data in your binary, and currently you need a fresh build whenever you add new files. <a href="https://github.com/XAMPPRocky/fluent-templates/issues/2">https://github.com/XAMPPRocky/fluent-templates/issues/2</a></p>



<a name="221755624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221755624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221755624">(Jan 06 2021 at 11:09)</a>:</h4>
<p>Interesting, I'd have expected the mtime of the dir to change if you added a file to it, does it not?</p>



<a name="221761538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221761538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221761538">(Jan 06 2021 at 12:28)</a>:</h4>
<p>It does for files added directly in that directory, but not nested ones: <a href="https://serverfault.com/a/388100">https://serverfault.com/a/388100</a></p>



<a name="221765396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221765396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221765396">(Jan 06 2021 at 13:17)</a>:</h4>
<p>Okay, so if I were to want to do this I'd need to add all the dirs and all the files in the dirs, as rerun-if-changed and that ought to do the trick?</p>



<a name="221766817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221766817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221766817">(Jan 06 2021 at 13:32)</a>:</h4>
<p>That's what <a href="http://docs.rs">docs.rs</a> does, yeah <span class="user-mention" data-user-id="223910">@Daniel Silverstone</span></p>



<a name="221766845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221766845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221766845">(Jan 06 2021 at 13:32)</a>:</h4>
<p>Don't have the link on me but you can read the build script for examples</p>



<a name="221767261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221767261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221767261">(Jan 06 2021 at 13:36)</a>:</h4>
<p><span class="user-mention" data-user-id="223910">@Daniel Silverstone</span> and <span class="user-mention" data-user-id="219696">@XAMPPRocky</span> BTW this improved recently. <a href="https://github.com/rust-lang/cargo/pull/8973">https://github.com/rust-lang/cargo/pull/8973</a> You can thank <span class="user-mention" data-user-id="120518">@Eric Huss</span> for that.</p>



<a name="221768422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221768422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221768422">(Jan 06 2021 at 13:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120179">Eh2406</span> <a href="#narrow/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory/near/221767261">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="223910">Daniel Silverstone</span> and <span class="user-mention silent" data-user-id="219696">XAMPPRocky</span> BTW this improved recently. <a href="https://github.com/rust-lang/cargo/pull/8973">https://github.com/rust-lang/cargo/pull/8973</a> You can thank <span class="user-mention silent" data-user-id="120518">Eric Huss</span> for that.</p>
</blockquote>
<p>Oh this is exciting, thank you.<br>
(and thanks Joshua, I'll poke at <a href="http://docs.rs">docs.rs</a>' build script for now)</p>



<a name="221811084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221811084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221811084">(Jan 06 2021 at 19:28)</a>:</h4>
<p>Directories marine doesn't change when files change either.</p>



<a name="221811153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221811153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221811153">(Jan 06 2021 at 19:29)</a>:</h4>
<p>But I guess you only care about the listing.</p>



<a name="221867237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221867237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221867237">(Jan 07 2021 at 08:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory/near/221811084">said</a>:</p>
<blockquote>
<p>Directories marine doesn't change when files change either.</p>
</blockquote>
<p>Yeah, I know directory mtime only changes if the <em>directory</em> changes, and since that is the filename -&gt; inode binding (at least under *nix) I'd intend to add the files to the rerun-if-changed list too.  Thanks for the reminder though, it's useful to note it in the thread.</p>



<a name="221980547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/221980547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#221980547">(Jan 07 2021 at 18:23)</a>:</h4>
<p><span class="user-mention" data-user-id="223910">@Daniel Silverstone</span> If you're willing to rely on current Cargo, you don't need to add the corresponding files, as Cargo will do that for you.</p>



<a name="222049205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/222049205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Silverstone <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#222049205">(Jan 08 2021 at 08:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory/near/221980547">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="223910">Daniel Silverstone</span> If you're willing to rely on current Cargo, you don't need to add the corresponding files, as Cargo will do that for you.</p>
</blockquote>
<p>Currently the project in question has a MSRV of whatever is in Debian/buster - will the rerun-if-changed=dir support be in Bullseye?</p>



<a name="222096857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/222096857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#222096857">(Jan 08 2021 at 17:00)</a>:</h4>
<p>well <a href="https://packages.debian.org/search?suite=bullseye&amp;searchon=names&amp;keywords=rustc">this listing</a> on the debian page says that bullseye is on rustc 1.48.</p>
<p>if the fix is that PR linked above from 27 days ago then it won't be in 1.48, though Bullseye might move to a newer rust before it changes over from Testing to Stable</p>



<a name="222098700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/rerun-if-changed%20on%20directory/near/222098700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/rerun-if-changed.20on.20directory.html#222098700">(Jan 08 2021 at 17:14)</a>:</h4>
<p>That PR is included in 1.50</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>